// Copyright 2011 The Avalon Project Authors. All rights reserved.
// Use of this source code is governed by the Apache License 2.0
// that can be found in the LICENSE file.
// Steffen Grundmann, June 2011
#include "wrap_around_filter.h"

#include "helmsman/lib/array_size.h"
#include "helmsman/lib/delta_angle.h"
#include "helmsman/lib/normalize.h"
#include "lib/testing/testing.h"
#include "../stopwatch.h"

#include "low_pass_filter.h"
#include "median_filter.h"
#include "polar_filter.h"
#include "quick_sliding_average_filter.h"
#include "sliding_average_filter.h"
#include "wrap_around_filter.h"

typedef long long int64;

int64 Now() {
  assert(sizeof(int64) == 8);
  return StopWatch::GetTimestampMicros();
}

ATEST(WrapAroundFilter, SlidingValidDCGainSetOutput) {
  WrapAroundFilter f(new SlidingAverageFilter(5));
  f.SetOutput(2);
  for (int i = 0; i < 20; ++i) {
    double out = f.Filter(2);
    EXPECT_FLOAT_EQ(2, out);
    EXPECT_TRUE(f.ValidOutput());
  }
}

ATEST(WrapAroundFilter, SlidingValidDCGain) {
  WrapAroundFilter f(new SlidingAverageFilter(5));
  for (int i = 0; i < 20; ++i) {
    double out = f.Filter(2);
    if (i >= 4) {
      EXPECT_TRUE(f.ValidOutput());
      EXPECT_FLOAT_EQ(2, out);
    } else {
      EXPECT_FALSE(f.ValidOutput());
    }
  }
}

ATEST(WrapAroundFilter, SlidingFiftyPercent) {
  WrapAroundFilter f(new SlidingAverageFilter(10));
  for (int i = 0; i < 20; ++i) {
    double out = f.Filter(1);
    if (i == 4)
      EXPECT_FLOAT_EQ(1 * 0.5, out);
  }
}

ATEST(WrapAroundFilter, SlidingZigZag) {
  WrapAroundFilter f(new SlidingAverageFilter(10));
  f.SetOutput(2);
  for (int i = 0; i < 20; ++i) {
    double out = f.Filter(i % 3 - 1 + 2);
    EXPECT_LT(1.85, out);
    EXPECT_GT(2.15, out);
  }
}


ATEST(WrapAroundFilter, Median5ValidDCGainSetOutput) {
  WrapAroundFilter f(new Median5Filter());
  f.SetOutput(2);
  for (int i = 0; i < 20; ++i) {
    double out = f.Filter(2);
    EXPECT_FLOAT_EQ(2, out);
    EXPECT_TRUE(f.ValidOutput());
  }
}

ATEST(WrapAroundFilter, Median5ValidDCGain) {
  WrapAroundFilter f(new Median5Filter());
  for (int i = 0; i < 20; ++i) {
    double out = f.Filter(2);
    if (i >= 4) {
      EXPECT_TRUE(f.ValidOutput());
      EXPECT_FLOAT_EQ(2, out);
    } else {
      EXPECT_FALSE(f.ValidOutput());
    }
  }
}

ATEST(WrapAroundFilter, Median3) {
  WrapAroundFilter f(new Median3Filter());
  for (int i = 0; i < 20; ++i) {
    double out = f.Filter(1);
    if (i >= 2) {
      EXPECT_TRUE(f.ValidOutput());
      EXPECT_EQ(1, out);
    } else {
      EXPECT_FALSE(f.ValidOutput());
    }
  }
}

ATEST(WrapAroundFilter, Median3ZigZag) {
  WrapAroundFilter f(new Median3Filter());
  f.SetOutput(2);
  for (int i = 0; i < 20; ++i) {
    double out = f.Filter(i % 3 - 1 + 2);
    EXPECT_EQ(2, out);
  }
}

ATEST(WrapAroundFilter, LowPass1FilterZigZagValid) {
  WrapAroundFilter f(new LowPass1Filter(10));
  for (int i = 0; i < 20; ++i) {
    f.Filter(i % 3 - 1 + 2);
    if (i >= 9) {
      EXPECT_TRUE(f.ValidOutput());
    } else {
      EXPECT_FALSE(f.ValidOutput());
    }
  }
}


ATEST(WrapAroundFilter, LowPass1FilterZigZag) {
  WrapAroundFilter f(new LowPass1Filter(10));
  f.SetOutput(2);
  for (int i = 0; i < 20; ++i) {
    double out = f.Filter(i % 3 - 1 + 2);
    EXPECT_LT(1.85, out);
    EXPECT_GT(2.15, out);
    EXPECT_TRUE(f.ValidOutput());
  }
}

ATEST(WrapAroundFilter, AllFilterRamp) {
  WrapAroundFilter f1(new SlidingAverageFilter(10));
  WrapAroundFilter f2(new LowPass1Filter(10));
  WrapAroundFilter f3(new Median3Filter());
  WrapAroundFilter f4(new Median5Filter());
  double prev1;
  double prev2;
  double prev3;
  double prev4;
  double increment = 2 * M_PI / 5;
  for (int cnt = 0; cnt < 50; ++cnt) {
    double in = NormalizeRad(cnt * increment);
    double out1 = f1.Filter(in);
    double out2 = f2.Filter(in);
    double out3 = f3.Filter(in);
    double out4 = f4.Filter(in);
    printf("%6.4lf %6.4lf %6.4lf %6.4lf\n", out1, out2, out3, out4);
    if (cnt == 1) {
      EXPECT_FALSE(f1.ValidOutput());
      EXPECT_FALSE(f2.ValidOutput());
      EXPECT_FALSE(f3.ValidOutput());
      EXPECT_FALSE(f4.ValidOutput());
    }
    if (cnt > 10) {
      EXPECT_TRUE(f1.ValidOutput());
      EXPECT_TRUE(f2.ValidOutput());
      EXPECT_TRUE(f3.ValidOutput());
      EXPECT_TRUE(f4.ValidOutput());
    }

    EXPECT_IN_INTERVAL(0, out1, 2 * M_PI);
    EXPECT_IN_INTERVAL(0, out2, 2 * M_PI);
    EXPECT_IN_INTERVAL(0, out3, 2 * M_PI);
    EXPECT_IN_INTERVAL(0, out4, 2 * M_PI);
    // In steady state, the output follows the input with the same gradient.
    if (cnt > 200) {
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev1, out1));
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev2, out2));
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev3, out3));
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev4, out4));
    }
    prev1 = out1;
    prev2 = out2;
    prev3 = out3;
    prev4 = out4;
  }
}

ATEST(WrapAroundFilter, AllFilterRampNegative) {
  WrapAroundFilter f1(new SlidingAverageFilter(10));
  WrapAroundFilter f2(new LowPass1Filter(10));
  WrapAroundFilter f3(new Median3Filter());
  WrapAroundFilter f4(new Median5Filter());
  double prev1;
  double prev2;
  double prev3;
  double prev4;
  double increment = -2 * M_PI / 5;
  for (int cnt = 0; cnt < 50; ++cnt) {
    double in = NormalizeRad(cnt * increment);
    double out1 = f1.Filter(in);
    double out2 = f2.Filter(in);
    double out3 = f3.Filter(in);
    double out4 = f4.Filter(in);
    printf("%6.4lf %6.4lf %6.4lf %6.4lf\n", out1, out2, out3, out4);
    if (cnt == 1) {
      EXPECT_FALSE(f1.ValidOutput());
      EXPECT_FALSE(f2.ValidOutput());
      EXPECT_FALSE(f3.ValidOutput());
      EXPECT_FALSE(f4.ValidOutput());
    }
    if (cnt > 10) {
      EXPECT_TRUE(f1.ValidOutput());
      EXPECT_TRUE(f2.ValidOutput());
      EXPECT_TRUE(f3.ValidOutput());
      EXPECT_TRUE(f4.ValidOutput());
    }

    EXPECT_IN_INTERVAL(0, out1, 2 * M_PI);
    EXPECT_IN_INTERVAL(0, out2, 2 * M_PI);
    EXPECT_IN_INTERVAL(0, out3, 2 * M_PI);
    EXPECT_IN_INTERVAL(0, out4, 2 * M_PI);
    // In steady state, the output follows the input with the same gradient.
    if (cnt > 200) {
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev1, out1));
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev2, out2));
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev3, out3));
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev4, out4));
    }
    prev1 = out1;
    prev2 = out2;
    prev3 = out3;
    prev4 = out4;
  }
}

ATEST(WrapAroundFilter, AllFilterRampElegant) {
  WrapAroundFilter f1(new SlidingAverageFilter(10));
  WrapAroundFilter f2(new LowPass1Filter(10));
  WrapAroundFilter f3(new Median3Filter());
  WrapAroundFilter f4(new Median5Filter());
  WrapAroundFilter* filter[4] = {&f1, &f2, &f3, &f4};
  double prev;
  double increment = 1;
  for  (int n = 0; n < ARRAY_SIZE(filter); ++n) {
    prev = 0;
    for (int cnt = 0; cnt < 5000; ++cnt) {
      double in = NormalizeRad(cnt * increment);
      double out = filter[n]->Filter(in);
      //printf("%6.4lf %6.4lf %6.4lf %6.4lf\n", out1, out2, out3, out4);

      EXPECT_IN_INTERVAL(0, out, 2 * M_PI);

      if (cnt < 2)  // Median3
        EXPECT_FALSE(filter[n]->ValidOutput());
      if (cnt > 10)
        EXPECT_TRUE(filter[n]->ValidOutput());
      // In steady state, the output follows the input with the same gradient.
      if (cnt > 200) {
        EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev, out));
      }
      prev = out;
    }
  }
}

ATEST(WrapAroundFilter, AllFilterRampShiftBack) {
  WrapAroundFilter f1(new SlidingAverageFilter(10));
  WrapAroundFilter f2(new LowPass1Filter(10));
  WrapAroundFilter f3(new Median3Filter());
  WrapAroundFilter f4(new Median5Filter());
  WrapAroundFilter* filter[4] = {&f1, &f2, &f3, &f4};
  double prev;
  double increment = 0.84359643;
  for  (int n = 0; n < ARRAY_SIZE(filter); ++n) {
    prev = 0;
    for (int cnt = 0; cnt < 5000; ++cnt) {
      double in = NormalizeRad(cnt * increment);
      double out = filter[n]->Filter(in);
      //printf("%6.4lf %6.4lf %6.4lf %6.4lf\n", out1, out2, out3, out4);

      EXPECT_IN_INTERVAL(0, out, 2 * M_PI);

      if (cnt < 2)  // Median3
        EXPECT_FALSE(filter[n]->ValidOutput());
      if (cnt > 10)
        EXPECT_TRUE(filter[n]->ValidOutput());
      // In steady state, the output follows the input with the same gradient.
      if (cnt > 200) {
        EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev, out));
      }
      prev = out;
    }
  }
}

ATEST(WrapAroundFilter, AllFilterRampShiftBackNegative) {
  WrapAroundFilter f1(new SlidingAverageFilter(10));
  WrapAroundFilter f2(new LowPass1Filter(10));
  WrapAroundFilter f3(new Median3Filter());
  WrapAroundFilter f4(new Median5Filter());
  WrapAroundFilter* filter[4] = {&f1, &f2, &f3, &f4};
  double prev;
  double increment = -0.84359643;
  for  (int n = 0; n < ARRAY_SIZE(filter); ++n) {
    prev = 0;
    for (int cnt = 0; cnt < 5000; ++cnt) {
      double in = NormalizeRad(cnt * increment);
      double out = filter[n]->Filter(in);

      EXPECT_IN_INTERVAL(0, out, 2 * M_PI);

      if (cnt < 2)  // Median3
        EXPECT_FALSE(filter[n]->ValidOutput());
      if (cnt > 10)
        EXPECT_TRUE(filter[n]->ValidOutput());

      //printf("%4d %6.4lf %6.4lf\n", cnt, in, out);

      // In steady state, the output follows the input with the same gradient.
      if (cnt > 200) {
        EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev, out));
      }
      prev = out;
    }
  }
}

ATEST(WrapAroundFilter, QuickSlidingMean1) {
  WrapAroundFilter f6(new QuickSlidingAverageFilter(1000));
  double prev6;
  double increment = 0;
  const int rounds = 2000;
  for (int cnt = 0; cnt < rounds; ++cnt) {
    double in = 2;
    double out6 = f6.Filter(in);
    printf("%6.4lf\n", out6);

    EXPECT_IN_INTERVAL(0, out6, 2 * M_PI);

    // In steady state, the output follows the input with the same gradient.
    if (cnt > 1000) {
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev6, out6));
    }
    if (cnt < 499)
      EXPECT_FALSE(f6.ValidOutput());
    if (cnt >= 499)
      EXPECT_TRUE(f6.ValidOutput());

    prev6 = out6;
  }
}


struct AlphaMag {
  double alpha;
  double mag;
};

static const AlphaMag example[] = {
    {-3.0754, 7.85313},
    {-2.05393, 7.88592},
    {-1.02438, 7.91078},
    {-0.0192698, 7.89563},
    {0.993055, 7.85141},
    {2.00587, 7.82216},
    {2.01961, 7.82063},
    {2.01576, 7.81937},
    {2.0187, 7.81817},
    {2.02179, 7.81708},
    {2.03045, 7.66602},
    {2.03334, 7.66411},
    {2.0263, 7.66218},
    {2.02925, 7.65874},
    {2.02898, 7.6553},
    {2.05262, 7.65075},
    {2.07516, 7.6462},
    {2.10053, 7.64136},
    {2.12478, 7.63652},
    {2.13078, 7.63142},
    {2.04277, 7.62625},
    {2.04305, 7.62172},
    {2.02907, 7.61718},
    {1.99683, 7.61363},
    {1.96576, 7.61008},
    {1.92593, 7.60716},
    {1.89741, 7.60423},
    {1.86314, 7.60127},
    {1.84602, 7.5983},
    {1.83158, 7.59532},
    {1.74274, 7.23323},
    {1.74239, 7.22997},
    {1.74816, 7.22671},
    {1.76203, 7.22331},
    {1.77135, 7.21992},
    {1.78459, 7.21694},
    {1.79047, 7.21397},
    {1.78954, 7.21163},
    {1.78861, 7.2093},
    {1.78221, 7.20694},
    {1.8102, 7.51396},
    {1.79179, 7.51213},
    {1.78524, 7.51027},
    {1.77457, 7.50831},
    {1.76944, 7.50636},
    {1.76123, 7.50414},
    {1.75325, 7.50191},
    {1.75381, 7.49972},
    {1.75379, 7.49753},
    {1.75469, 7.49511},
    {1.81686, 7.90207},
    {1.82957, 7.89978},
    {1.83782, 7.89749},
    {1.84318, 7.89547},
    {1.84287, 7.89346},
    {1.84256, 7.89198},
    {1.8337, 7.89051},
    {1.81528, 7.88978},
    {1.7996, 7.88904},
    {1.77175, 7.8884},
    {1.87685, 8.29826},
    {1.84581, 8.29829},
    {1.82443, 8.29833},
    {1.79747, 8.29858},
    {1.78178, 8.29882},
    {1.76909, 8.29857},
    {1.76688, 8.29831},
    {1.76689, 8.29682},
    {1.76691, 8.29534},
    {1.78607, 8.29375},
    {1.83024, 8.75286},
    {1.85355, 8.75022},
    {1.86962, 8.74759},
    {1.89065, 8.74479},
    {1.90593, 8.74201},
    {1.91017, 8.73995},
    {1.91109, 8.73789},
    {1.91199, 8.73738},
    {1.89101, 8.73687},
    {1.85605, 8.73632},
    {1.94956, 8.79068},
    {1.8289, 8.79104},
    {1.79531, 8.79141},
    {1.74612, 8.79124},
    {1.71882, 8.79108},
    {1.70306, 8.78904},
    {1.67526, 8.787},
    {1.673, 8.78466},
    {1.67307, 8.78231},
    {1.6755, 8.77874},
    {1.73119, 8.93849},
    {1.75961, 8.93472},
    {1.81007, 8.93095},
    {1.8381, 8.92773},
    {1.84956, 8.9245},
    {1.84963, 8.9223},
    {1.84971, 8.9201},
    {1.84919, 8.91927},
    {1.84272, 8.91844},
    {1.82195, 8.91783},
    {1.89423, 8.51485},
    {1.87341, 8.515},
    {1.8653, 8.51516},
    {1.8653, 8.5153},
    {1.86529, 8.51544},
    {1.86875, 8.51518},
    {1.87523, 8.51492},
    {1.91697, 8.51471},
    {1.93158, 8.5145},
    {1.98688, 8.51448},
    {2.00553, 8.81443},
    {2.04259, 8.81479},
    {2.0563, 8.81516},
    {2.07273, 8.81612},
    {2.07917, 8.81708},
    {2.07909, 8.81882},
    {2.07276, 8.81978},
    {2.06744, 8.82052},
    {2.08643, 8.82129},
    {2.17839, 8.82239},
    {2.21549, 9.545},
    {2.22036, 9.5459},
    {2.23315, 9.54753},
    {2.25754, 9.54932},
    {2.28903, 9.55111},
    {2.31366, 9.55288},
    {2.35276, 9.55464},
    {2.37525, 9.55594},
    {2.38526, 9.55725},
    {2.38687, 9.55888},
    {2.30272, 10.4839},
    {2.30269, 10.4858},
    {2.30692, 10.4877},
    {2.31767, 10.4891},
    {2.33049, 10.4905},
    {2.35593, 10.4909},
    {2.38767, 10.4912},
    {2.43819, 10.4905},
    {2.4928, 10.4898},
    {2.5639, 10.4884},
    {2.45952, 10.6894},
    {2.51279, 10.6882},
    {2.5232, 10.687},
    {2.5336, 10.6869},
    {2.52048, 10.6869},
    {2.50562, 10.6883},
    {2.49, 10.6892},
    {2.48316, 10.6895},
    {2.47662, 10.6898},
    {2.46901, 10.6903},
    {2.18056, 9.97075},
    {2.20957, 9.97065},
    {2.21396, 9.97039},
    {2.29049, 9.96858},
    {2.28838, 9.96678},
    {2.34397, 9.96422},
    {2.35184, 9.96172},
    {2.37794, 9.95985},
    {2.3861, 9.95798},
    {2.38428, 9.95572},
    {2.09608, 9.30381},
    {2.09383, 9.30327},
    {2.08493, 9.30258},
    {2.06542, 9.30279},
    {2.05226, 9.30301},
    {2.05197, 9.30325},
    {2.05168, 9.30349},
    {2.05826, 9.30355},
    {2.06976, 9.30362},
    {2.08285, 9.30317},
    {1.92669, 8.55217},
    {1.93564, 8.55148},
    {1.9373, 8.55079},
    {1.93839, 8.55006},
    {1.93903, 8.54933},
    {1.94043, 8.5489},
    {1.9404, 8.54847},
    {1.94624, 8.54864},
    {1.95346, 8.54881},
    {1.96018, 8.54892},
    {1.88801, 8.19951},
    {1.88808, 8.20026},
    {1.88816, 8.20101},
    {1.88489, 8.20227},
    {1.88213, 8.20352},
    {1.87922, 8.20515},
    {1.8765, 8.20677},
    {1.87669, 8.2087},
    {1.87688, 8.21063},
    {1.88572, 8.21257},
    {1.85836, 7.95968},
    {1.87624, 7.96181},
    {1.89555, 7.96394},
    {1.91868, 7.96641},
    {1.93802, 7.96888},
    {1.97662, 7.97164},
    {1.99023, 7.9744},
    {2.00298, 7.97742},
    {2.00498, 7.98044},
    {2.00533, 7.98369},
    {1.93508, 8.19597},
    {1.93121, 8.19912},
    {1.92582, 8.20227},
    {1.92313, 8.20556},
    {1.91921, 8.20886},
    {1.91503, 8.2124},
    {1.91258, 8.21594},
    {1.91146, 8.21995},
    {1.90907, 8.22395},
    {1.90297, 8.22831},
    {1.85702, 8.49609},
    {1.83415, 8.50089},
    {1.82783, 8.5057},
    {1.80856, 8.51088},
    {1.80342, 8.5161},
    {1.80406, 8.52116},
    {1.80498, 8.5262},
    {1.86054, 8.53067},
    {1.88708, 8.53514},
    {1.90991, 8.53983},
    {1.95709, 8.80534},
    {2.07923, 8.80903},
    {2.08321, 8.81277},
    {2.08714, 8.8161},
    {2.05857, 8.81912},
    {1.96655, 8.8227},
    {1.91927, 8.82613},
    {1.8603, 8.82995},
    {1.83382, 8.83396},
    {1.81104, 8.83904},
    {1.73888, 8.74478},
    {1.77321, 8.75049},
    {1.79586, 8.75648},
    {1.82673, 8.76261},
    {1.89148, 8.76909},
    {1.98018, 8.77526},
    {2.08918, 8.78183},
    {2.24287, 8.78766},
    {2.31866, 8.79361},
    {2.34911, 8.80005},
    {2.33484, 8.4953},
    {2.31692, 8.50156},
    {2.27491, 8.50758},
    {2.22119, 8.51415},
    {2.18457, 8.52079},
    {2.13621, 8.52801},
    {2.11082, 8.53528},
    {2.09175, 8.54245},
    {2.09181, 8.54962},
    {2.09188, 8.55706},
    {2.49187, 6.5649},
    {2.59524, 6.57291},
    {2.67055, 6.58092},
    {2.77433, 6.58853},
    {2.89161, 6.59614},
    {2.93191, 6.60343},
    {2.93162, 6.61072},
    {2.93134, 6.6181},
    {2.91072, 6.62549},
    {2.88732, 6.63302},
    {-2.79948, 4.8496},
    {-2.81411, 4.85608},
    {-2.82817, 4.86257},
    {-2.83786, 4.8694},
    {-2.84762, 4.87624},
    {-2.84862, 4.88311},
    {-2.84934, 4.88995},
    {-2.84539, 4.89692},
    {-2.81691, 4.9039},
    {-2.76324, 4.91031},
    {-1.88664, 3.31735},
    {-1.81492, 3.3182},
    {-1.75566, 3.31915},
    {-1.66894, 3.3201},
    {-1.67103, 3.32107},
    {-1.67315, 3.32205},
    {-1.68543, 3.32296},
    {-1.70841, 3.32398},
    {-1.72361, 3.32502},
    {-1.73189, 3.32585},
    {-1.08284, 3.05297},
    {-1.08458, 3.04946},
    {-1.08664, 3.04605},
    {-1.08252, 3.04267},
    {-1.07427, 3.0393},
    {-1.0551, 3.03624},
    {-1.03851, 3.03329},
    {-1.02613, 3.03032},
    {-1.00771, 3.02737},
    {-0.986748, 3.02474},
    {-0.733388, 2.42999},
    {-0.712767, 2.42612},
    {-0.702431, 2.42216},
    {-0.696726, 2.4181},
    {-0.686042, 2.41404},
    {-0.680207, 2.4098},
    {-0.67625, 2.40728},
    {-0.666144, 2.4049},
    {-0.671868, 2.40258},
    {-0.633488, 2.40064},
    {-0.507794, 1.64111},
    {-0.500511, 1.64765},
    {-0.481597, 1.65297},
    {-0.474172, 1.65901},
    {-0.486485, 1.66554},
    {-0.512457, 1.67765},
    {-0.557601, 1.69092},
    {-0.587587, 1.6992},
    {-0.633966, 1.70789},
    {-0.686601, 1.7173},
    {-0.471185, 1.08814},
    {-0.522022, 1.1014},
    {-0.555785, 1.10981},
    {-0.56649, 1.11888},
    {-0.570825, 1.12835},
    {-0.581616, 1.14373},
    {-0.600924, 1.15985},
    {-0.611945, 1.17051},
    {-0.638708, 1.18138},
    {-0.677503, 1.19766},
    {0.0911964, 1.06614},
    {0.0272714, 1.07473},
    {-0.0179871, 1.08081},
    {-0.0644863, 1.08879},
    {-0.118309, 1.09946},
    {-0.15966, 1.10887},
    {-0.208809, 1.12028},
    {-0.249327, 1.1287},
    {-0.291019, 1.13713},
    {-0.35034, 1.15031},
    {0.555672, 1.38602},
    {0.500924, 1.39027},
    {0.459697, 1.39558},
    {0.409099, 1.40188},
    {0.356574, 1.40818},
    {0.31547, 1.4163},
    {0.275644, 1.42471},
    {0.251364, 1.43526},
    {0.22808, 1.446},
    {0.201892, 1.45783},
    {1.25118, 2.7775},
    {1.23333, 2.78172},
    {1.21576, 2.78903},
    {1.18516, 2.7976},
    {1.13662, 2.80618},
    {1.09239, 2.81568},
    {1.04737, 2.82516},
    {1.00109, 2.83524},
    {0.968501, 2.84541},
    {0.936697, 2.85442},
    {1.57216, 5.07918},
    {1.56905, 5.0792},
    {1.56622, 5.07934},
    {1.62894, 5.0795},
    {1.68245, 5.0797},
    {1.73498, 5.07995},
    {1.76113, 5.0803},
    {1.76109, 5.08073},
    {1.75829, 5.0812},
    {1.75258, 5.08173},
    {2.27232, 7.42798},
    {2.25038, 7.42019},
    {2.17937, 7.41248},
    {2.10423, 7.40554},
    {2.04629, 7.39838},
    {2.00717, 7.39263},
    {1.97947, 7.38702},
    {1.96979, 7.38173},
    {1.96436, 7.37652},
    {1.95917, 7.37232},
    {1.79079, 8.44487},
    {1.85942, 8.44271},
    {1.90923, 8.44048},
    {1.91435, 8.43804},
    {1.95056, 8.4355},
    {1.97739, 8.43255},
    {1.98911, 8.42936},
    {1.99565, 8.42632},
    {1.96742, 8.42315},
    {1.93685, 8.41982},
    {1.96725, 8.56167},
    {1.92491, 8.55886},
    {1.90088, 8.55607},
    {1.881, 8.55422},
    {1.87014, 8.55237},
    {1.85603, 8.551},
    {1.84844, 8.54961},
    {1.84807, 8.54829},
    {1.8477, 8.54697},
    {1.86237, 8.54547},
    {1.82483, 8.5987},
    {1.86687, 8.5946},
    {1.91227, 8.59034},
    {1.93338, 8.58576},
    {1.9545, 8.581},
    {1.95689, 8.57534},
    {1.95226, 8.5692},
    {1.93489, 8.5655},
    {1.93571, 8.56177},
    {1.93889, 8.55815},
    {1.94351, 9.02536},
    {1.96242, 9.0209},
    {1.9429, 9.01802},
    {1.96549, 9.01506},
    {1.99897, 9.01085},
    {2.04009, 9.00608},
    {2.10068, 9.00255},
    {2.14426, 8.99836},
    {2.16466, 8.99414},
    {2.18482, 8.99023},
    {2.07296, 9.40779},
    {2.03213, 9.40478},
    {1.99536, 9.4017},
    {1.94444, 9.39992},
    {1.90515, 9.39814},
    {1.86368, 9.39669},
    {1.8541, 9.3952},
    {1.84997, 9.39401},
    {1.84009, 9.39285},
    {1.83978, 9.39187},
    {1.77769, 9.18821},
    {1.77077, 9.18708},
    {1.77093, 9.186},
    {1.77101, 9.18433},
    {1.79194, 9.18265},
    {1.82577, 9.1802},
    {1.86175, 9.1778},
    {1.86112, 9.17526},
    {1.86049, 9.17271},
    {1.75677, 9.17035},
    {1.72473, 9.37796},
    {1.6881, 9.37589},
    {1.66758, 9.37376},
    {1.64311, 9.37194},
    {1.62696, 9.37012},
    {1.59832, 9.36827},
    {1.57464, 9.36646},
    {1.54751, 9.36411},
    {1.54691, 9.36176},
    {1.54631, 9.35943},
    {1.60764, 9.70787},
    {1.61909, 9.7062},
    {1.62949, 9.70453},
    {1.63478, 9.70324},
    {1.62797, 9.702},
    {1.62127, 9.7017},
    {1.61871, 9.70059},
    {1.60297, 9.69882},
    {1.58588, 9.69705},
    {1.55453, 9.6958},
    {1.62489, 10.09},
    {1.62859, 10.0877},
    {1.632, 10.0855},
    {1.64199, 10.0821},
    {1.6759, 10.0785},
    {1.7134, 10.074},
    {1.73432, 10.0694},
    {1.74507, 10.066},
    {1.74414, 10.0627},
    {1.74318, 10.0591},
    {1.83742, 10.3932},
    {1.81728, 10.3909},
    {1.78941, 10.3886},
    {1.73873, 10.3876},
    {1.71217, 10.3865},
    {1.69603, 10.3857},
    {1.69687, 10.3848},
    {1.69713, 10.3842},
    {1.69503, 10.3836},
    {1.69522, 10.3821},
    {1.84162, 10.1943},
    {1.86842, 10.1911},
    {1.8928, 10.1879},
    {1.92205, 10.184},
    {1.93495, 10.18},
    {1.94225, 10.1763},
    {1.94235, 10.1726},
    {1.94221, 10.1701},
    {1.9321, 10.1677},
    {1.90514, 10.1652},
    {1.92478, 10.1034},
    {1.89896, 10.102},
    {1.88748, 10.1007},
    {1.87977, 10.0995},
    {1.87971, 10.0983},
    {1.87961, 10.0962},
    {1.88521, 10.0942},
    {1.89482, 10.0911},
    {1.89466, 10.088},
    {1.89688, 10.0848},
    {1.93255, 9.87567},
    {1.94682, 9.87234},
    {1.95806, 9.86901},
    {1.9688, 9.86637},
    {1.96909, 9.86373},
    {1.96902, 9.8623},
    {1.96925, 9.86081},
    {1.95079, 9.85999},
    {1.93966, 9.85917},
    {1.93915, 9.85847},
    {1.93847, 9.33785},
    {1.93446, 9.33716},
    {1.93473, 9.33652},
    {1.93083, 9.33549},
    {1.91855, 9.3344},
    {1.89903, 9.33295},
    {1.89332, 9.33149},
    {1.89325, 9.33021},
    {1.89319, 9.32892},
    {1.90319, 9.32761},
    {1.94615, 9.22038},
    {1.96059, 9.21938},
    {1.97419, 9.21843},
    {1.98887, 9.2181},
    {2.00137, 9.21776},
    {2.00206, 9.21815},
    {2.00177, 9.21855},
    {2.00179, 9.21915},
    {1.99785, 9.21971},
    {1.99037, 9.22041},
    {2.02479, 8.70569},
    {2.023, 8.70625},
    {2.01762, 8.70681},
    {2.00851, 8.70695},
    {1.99852, 8.70709},
    {1.98894, 8.70689},
    {1.97325, 8.70668},
    {1.96588, 8.70653},
    {1.96063, 8.70638},
    {1.96033, 8.70653},
    {1.94187, 8.75935},
    {1.95953, 8.76015},
    {2.00947, 8.76095},
    {2.02766, 8.76252},
    {2.04657, 8.76408},
    {2.04698, 8.76626},
    {2.04738, 8.76844},
    {2.03613, 8.77085},
    {2.00767, 8.77326},
    {1.9793, 8.77589},
    {1.93793, 8.57123},
    {1.92269, 8.57332},
    {1.92229, 8.57541},
    {1.92235, 8.57658},
    {1.92241, 8.57776},
    {1.93977, 8.57826},
    {1.95549, 8.57877},
    {1.97465, 8.57923},
    {1.99036, 8.57968},
    {2.00136, 8.58014},
    {1.96488, 8.53615},
    {1.96495, 8.5373},
    {1.9536, 8.53844},
    {1.93894, 8.54052},
    {1.92906, 8.54259},
    {1.91899, 8.54529},
    {1.91342, 8.54799},
    {1.9102, 8.55075},
    {1.897, 8.55351},
    {1.89591, 8.55646},
    {1.91307, 8.14682},
    {1.91385, 8.14948},
    {1.92325, 8.15214},
    {1.93981, 8.15415},
    {1.95676, 8.15615},
    {1.9713, 8.1574},
    {1.97881, 8.15866},
    {1.9837, 8.15992},
    {1.98407, 8.16118},
    {1.98577, 8.16211},
    {2.0057, 8.16062},
    {2.00793, 8.16172},
    {2.00799, 8.16281},
    {2.00807, 8.16454},
    {2.00673, 8.16627},
    {2.00187, 8.16887},
    {1.99599, 8.17146},
    {1.98581, 8.17468},
    {1.97425, 8.1779},
    {1.9616, 8.18123},
    {1.95545, 8.02458},
    {1.95562, 8.02788},
    {1.95579, 8.03119},
    {1.98244, 8.03385},
    {1.99973, 8.03651},
    {2.02262, 8.03841},
    {2.04129, 8.0403},
    {2.05944, 8.04217},
    {2.07239, 8.04404},
    {2.08197, 8.04549},
    {2.10061, 8.35493},
    {2.10068, 8.35644},
    {2.09978, 8.35795},
    {2.09352, 8.35984},
    {2.08647, 8.36173},
    {2.07696, 8.36868},
    {2.06872, 8.37563},
    {2.06121, 8.38369},
    {2.05842, 8.39174},
    {2.05852, 8.40037},
    {2.02255, 8.26228},
    {2.03341, 8.27014},
    {2.04977, 8.27808},
    {2.06417, 8.28415},
    {2.07156, 8.29024},
    {2.07929, 8.29432},
    {2.08402, 8.2984},
    {2.09326, 8.30237},
    {2.10286, 8.30626},
    {2.11801, 8.30956},
    {2.09389, 8.51564},
    {2.1038, 8.51928},
    {2.11257, 8.5229},
    {2.11314, 8.52764},
    {2.1137, 8.53239},
    {2.10547, 8.53815},
    {2.09866, 8.54391},
    {2.09257, 8.55032},
    {2.08692, 8.55676},
    {2.08004, 8.56345},
    {2.02266, 8.47331},
    {2.0223, 8.47982},
    {2.01987, 8.48634},
    {2.01797, 8.49241},
    {2.01836, 8.49849},
    {2.01873, 8.50427},
    {2.02339, 8.51006},
    {2.02785, 8.51597},
    {2.02966, 8.52188},
    {2.03116, 8.52776},
    {2.00227, 8.89474},
    {2.01346, 8.90049},
    {2.02816, 8.90624},
    {2.04988, 8.91167},
    {2.06687, 8.91712},
    {2.10025, 8.92188},
    {2.10574, 8.92666},
    {2.10759, 8.9309},
    {2.10993, 8.93515},
    {2.11019, 8.93928},
    {2.04061, 9.15368},
    {2.0492, 9.15771},
    {2.05379, 9.16174},
    {2.06491, 9.1666},
    {2.06616, 9.17146},
    {2.06657, 9.17709},
    {2.06698, 9.18272},
    {2.0667, 9.18824},
    {2.0671, 9.19376},
    {2.06783, 9.19975},
    {2.01317, 9.30349},
    {2.04237, 9.30897},
    {2.06795, 9.31447},
    {2.09102, 9.31934},
    {2.10791, 9.32422},
    {2.12561, 9.32821},
    {2.141, 9.3322},
    {2.15941, 9.33539},
    {2.1646, 9.33854},
    {2.16484, 9.34146},
    {2.07893, 8.92845},
    {2.05887, 8.93078},
    {2.04895, 8.93312},
    {2.04365, 8.93558},
    {2.03663, 8.93803},
    {2.03083, 8.9411},
    {2.0224, 8.94416},
    {2.01386, 8.94814},
    {2.01064, 8.95212},
    {2.01104, 8.95613},
    {1.89165, 8.3272},
    {1.90818, 8.33115},
    {1.92772, 8.3351},
    {1.95676, 8.33846},
    {1.98348, 8.34183},
    {2.00238, 8.34389},
    {2.00266, 8.34594},
    {2.0027, 8.34622},
    {2.00157, 8.34651},
    {1.98153, 8.34677},
    {1.90901, 8.49978},
    {1.88646, 8.49917},
    {1.86146, 8.49855},
    {1.83207, 8.49858},
    {1.80572, 8.4986},
    {1.7774, 8.50015},
    {1.77582, 8.5017},
    {1.77608, 8.50343},
    {1.77634, 8.50516},
    {1.78249, 8.50736},
    {1.76506, 8.86407},
    {1.78589, 8.86561},
    {1.80236, 8.86719},
    {1.84218, 8.86745},
    {1.86418, 8.86771},
    {1.86427, 8.86647},
    {1.86436, 8.86524},
    {1.85198, 8.86323},
    {1.82438, 8.86117},
    {1.78781, 8.85874},
    {1.79662, 9.37129},
    {1.76611, 9.36907},
    {1.74567, 9.36685},
    {1.71168, 9.3653},
    {1.69127, 9.36375},
    {1.66646, 9.36254},
    {1.6663, 9.36133},
    {1.66607, 9.35969},
    {1.67297, 9.35805},
    {1.70804, 9.35623},
    {1.80558, 9.51064},
    {1.85385, 9.50753},
    {1.89091, 9.50442},
    {1.92519, 9.5001},
    {1.92467, 9.49578},
    {1.92402, 9.4905},
    {1.9162, 9.48522},
    {1.90428, 9.48009},
    {1.89503, 9.47496},
    {1.8703, 9.46956},
    {1.88122, 9.67634},
    {1.84135, 9.67157},
    {1.80064, 9.66681},
    {1.75757, 9.66278},
    {1.72554, 9.65875},
    {1.70891, 9.65493},
    {1.70848, 9.65111},
    {1.70808, 9.64754},
    {1.72781, 9.64398},
    {1.7968, 9.63979},
    {1.89571, 9.58648},
    {1.94705, 9.58103},
    {2.01557, 9.57557},
    {2.04859, 9.56972},
    {2.0477, 9.56387},
    {2.04692, 9.5592},
    {2.01462, 9.55453},
    {1.96792, 9.55203},
    {1.92584, 9.54953},
    {1.8141, 9.54749},
    {1.74907, 9.33587},
    {1.70727, 9.33525},
    {1.70721, 9.33464},
    {1.70739, 9.33366},
    {1.72672, 9.33269},
    {1.79122, 9.33035},
    {1.86335, 9.32802},
    {1.95044, 9.32607},
    {2.02123, 9.32412},
    {2.02093, 9.32133},
    {2.0382, 9.42781},
    {2.03777, 9.42541},
    {2.00419, 9.42303},
    {1.96549, 9.42202},
    {1.93211, 9.42102},
    {1.9053, 9.42095},
    {1.898, 9.42089},
    {1.89798, 9.42067},
    {1.89825, 9.42043},
    {1.91151, 9.42048},
    {1.87514, 9.62319},
    {1.87534, 9.62238},
    {1.87554, 9.62158},
    {1.86794, 9.62031},
    {1.82026, 9.61903},
    {1.79271, 9.61797},
    {1.77244, 9.61692},
    {1.77234, 9.61605},
    {1.77224, 9.61518},
    {1.80079, 9.61462},
    {1.84559, 9.92406},
    {1.89518, 9.92351},
    {1.9369, 9.92296},
    {1.93682, 9.92219},
    {1.93673, 9.92141},
    {1.91431, 9.92048},
    {1.88403, 9.91955},
    {1.84774, 9.91861},
    {1.82037, 9.91768},
    {1.79755, 9.9168},
    {1.79655, 9.81593},
    {1.79645, 9.81497},
    {1.79634, 9.81402},
    {1.81623, 9.81304},
    {1.83911, 9.81206},
    {1.86171, 9.81098},
    {1.86987, 9.8099},
    {1.86971, 9.80842},
    {1.86954, 9.80694},
    {1.86179, 9.80551},
    {1.91445, 9.84976},
    {1.91424, 9.8477},
    {1.91428, 9.84565},
    {1.92463, 9.84316},
    {1.92869, 9.84068},
    {1.92842, 9.83812},
    {1.92816, 9.83555},
    {1.92613, 9.83316},
    {1.9144, 9.83077},
    {1.89463, 9.82824},
    {1.91528, 9.82212},
    {1.89983, 9.81966},
    {1.8996, 9.81719},
    {1.89934, 9.81448},
    {1.90566, 9.81176},
    {1.90932, 9.80865},
    {1.91046, 9.80554},
    {1.91717, 9.80187},
    {1.91682, 9.79819},
    {1.9218, 9.79421},
    {1.94499, 9.88795},
    {1.94915, 9.88341},
    {1.95304, 9.87887},
    {1.96032, 9.87417},
    {1.9685, 9.86947},
    {1.9681, 9.86512},
    {1.96769, 9.86078},
    {1.96671, 9.85715},
    {1.95488, 9.85353},
    {1.94238, 9.84974},
    {1.91373, 9.58895},
    {1.91344, 9.58603},
    {1.91315, 9.58312},
    {1.92752, 9.58047},
    {1.9445, 9.57783},
    {1.97323, 9.57445},
    {1.99446, 9.57107},
    {1.99415, 9.56792},
    {1.99383, 9.56477},
    {1.98172, 9.56078},
    {1.89322, 9.51773},
    {1.85195, 9.51424},
    {1.81844, 9.51076},
    {1.78862, 9.50775},
    {1.78592, 9.50481},
    {1.78529, 9.50194},
    {1.78466, 9.49909},
    {1.81484, 9.4963},
    {1.87388, 9.49352},
    {1.91551, 9.49295},
    {1.96981, 9.38803},
    {1.98716, 9.38708},
    {1.96379, 9.38941},
    {1.94155, 9.39134},
    {1.86576, 9.39667},
    {1.76236, 9.39989},
    {1.69904, 9.40713},
    {1.62997, 9.41497},
    {1.58313, 9.41942},
    {1.54653, 9.42827},
    {1.52428, 9.7936},
    {1.5007, 9.79935},
    {1.48904, 9.80552},
    {1.47833, 9.81148},
    {1.47237, 9.82201},
    {1.46272, 9.82808},
    {1.47994, 9.83945},
    {1.48649, 9.8513},
    {1.46056, 9.86332},
    {1.43843, 9.87599},
    {1.56334, 10.4394},
    {1.54972, 10.4464},
    {1.54097, 10.4548},
    {1.54368, 10.4639},
    {1.53062, 10.4681},
    {1.50156, 10.4838},
    {1.4687, 10.5003},
    {1.44213, 10.5174},
    {1.44114, 10.53},
    {1.42253, 10.5388},
    {1.65153, 10.5578},
    {1.63249, 10.5518},
    {1.59934, 10.5377},
    {1.57525, 10.5229},
    {1.57598, 10.5057},
    {1.57727, 10.4858},
    {1.60139, 10.4655},
    {1.59835, 10.4447},
    {1.60141, 10.4241},
    {1.57944, 10.4029},
    {1.90833, 9.94001},
    {1.88287, 9.9184},
    {1.88636, 9.89226},
    {1.87611, 9.86685},
    {1.87766, 9.84724},
    {1.89079, 9.82298},
    {1.90184, 9.80367},
    {1.93054, 9.77849},
    {1.95484, 9.75737},
    {1.99051, 9.7326},
    {2.12185, 9.22123},
    {2.16246, 9.20184},
    {2.21072, 9.17973},
    {2.26704, 9.16152},
    {2.30954, 9.14182},
    {2.33355, 9.12603},
    {2.35764, 9.11061},
    {2.38153, 9.09741},
    {2.40339, 9.08473},
    {2.4118, 9.07223},
    {2.24617, 8.67341},
    {2.24467, 8.661},
    {2.24804, 8.64889},
    {2.2484, 8.63779},
    {2.2354, 8.62887},
    {2.2346, 8.62131},
    {2.2338, 8.61375},
    {2.24655, 8.60633},
    {2.26856, 8.59891},
    {2.31578, 8.59143},
    {2.12327, 8.74617},
    {2.16176, 8.73952},
    {2.1882, 8.73286},
    {2.1876, 8.72756},
    {2.18636, 8.7225},
    {2.1716, 8.72015},
    {2.14658, 8.71781},
    {2.11289, 8.71882},
    {2.08845, 8.72021},
    {2.02236, 8.72582},
    {1.82662, 8.09714},
    {1.81562, 8.10673},
    {1.80464, 8.11636},
    {1.80717, 8.13544},
    {1.7937, 8.16165},
    {1.81661, 8.18277},
    {1.84105, 8.20411},
    {1.88872, 8.23418},
    {1.92875, 8.26489},
    {1.97178, 8.29593},
    {1.93826, 8.41035},
    {1.93708, 8.43397},
    {1.89976, 8.46848},
    {1.87578, 8.49389},
    {1.82072, 8.52927},
    {1.79534, 8.55728},
    {1.77049, 8.58496},
    {1.74615, 8.6139},
    {1.742, 8.64107},
    {1.74612, 8.6762},
    {1.6858, 8.30073},
    {1.70334, 8.32467},
    {1.7298, 8.34784},
    {1.73987, 8.38116},
    {1.74908, 8.40414},
    {1.75904, 8.42716},
    {1.74098, 8.44917},
    {1.72706, 8.47775},
    {1.70161, 8.50476},
    {1.70618, 8.52108},
    {1.77135, 9.01661},
    {1.77759, 9.03138},
    {1.77633, 9.04545},
    {1.77844, 9.05966},
    {1.75814, 9.07908},
    {1.74644, 9.09733},
    {1.73776, 9.10905},
    {1.73863, 9.11977},
    {1.71463, 9.13567},
    {1.69632, 9.15014},
    {1.76407, 8.96081},
    {1.7526, 8.97},
    {1.72908, 8.98226},
    {1.70585, 8.99303},
    {1.68962, 9.0016},
    {1.69141, 9.00537},
    {1.68949, 9.00979},
    {1.68632, 9.01321},
    {1.68393, 9.01281},
    {1.69057, 9.01172},
    {1.8645, 9.01808},
    {1.88269, 9.01446},
    {1.90383, 9.01021},
    {1.94434, 9.00452},
    {1.99034, 8.9997},
    {2.03791, 8.99625},
    {2.08657, 8.99359},
    {2.14228, 8.99186},
    {2.18226, 8.99085},
    {2.21393, 8.99056},
    {2.20197, 8.84331},
    {2.23559, 8.84307},
    {2.25039, 8.84376},
    {2.25882, 8.84515},
    {2.25313, 8.84706},
    {2.25761, 8.8492},
    {2.27606, 8.85179},
    {2.28736, 8.85456},
    {2.30447, 8.8577},
    {2.33123, 8.86118},
    {2.27377, 8.69927},
    {2.31372, 8.70166},
    {2.3792, 8.70418},
    {2.40926, 8.70677},
    {2.41214, 8.70911},
    {2.4148, 8.71106},
    {2.35684, 8.71305},
    {2.31612, 8.71469},
    {2.27787, 8.71635},
    {2.24474, 8.71777},
    {2.00401, 8.80223},
    {1.97707, 8.8023},
    {1.9626, 8.80254},
    {1.95658, 8.80268},
    {1.9522, 8.80291},
    {1.95295, 8.80323},
    {1.95498, 8.80356},
    {1.9509, 8.8041},
    {1.94294, 8.80449},
    {1.9463, 8.80509},
    {1.87954, 8.74464},
    {1.88505, 8.74541},
    {1.91079, 8.74622},
    {1.92976, 8.74687},
    {1.95746, 8.74806},
    {1.96328, 8.749},
    {1.96887, 8.74992},
    {1.97137, 8.75034},
    {1.94082, 8.75074},
    {1.90677, 8.75103},
    {1.9356, 9.27072},
    {1.91197, 9.27013},
    {1.89121, 9.26956},
    {1.88777, 9.26913},
    {1.88512, 9.2686},
    {1.88319, 9.26825},
    {1.89981, 9.26791},
    {1.91019, 9.26753},
    {1.91391, 9.26716},
    {1.92221, 9.26665},
    {2.02743, 9.37805},
    {2.02511, 9.37697},
    {2.01993, 9.37591},
    {2.01564, 9.37463},
    {1.99254, 9.37337},
    {1.96875, 9.37217},
    {1.94911, 9.37096},
    {1.9482, 9.37003},
    {1.94729, 9.36912},
    {1.94842, 9.36786},
    {1.9902, 9.41833},
    {1.99918, 9.41727},
    {1.99595, 9.41613},
    {1.98844, 9.41497},
    {1.99372, 9.41394},
    {2.0068, 9.41275},
    {2.02959, 9.41162},
    {2.0336, 9.41045},
    {2.0368, 9.40925},
    {2.04105, 9.40765},
    {2.08906, 9.10417},
    {2.06179, 9.1017},
    {2.04606, 9.09914},
    {2.04563, 9.09719},
    {2.04753, 9.09538},
    {2.04417, 9.0945},
    {2.05593, 9.09358},
    {2.0688, 9.0927},
    {2.1038, 9.09192},
    {2.13224, 9.09095},
    {2.12934, 8.62109},
    {2.13268, 8.61928},
    {2.13807, 8.61723},
    {2.12607, 8.61456},
    {2.10432, 8.6116},
    {2.08797, 8.60898},
    {2.07312, 8.6063},
    {2.07824, 8.60321},
    {2.08043, 8.60044},
    {2.09718, 8.59803},
    {2.12879, 8.23318},
    {2.14005, 8.23174},
    {2.16334, 8.22991},
    {2.16817, 8.22876},
    {2.17798, 8.2268},
    {2.1738, 8.22527},
    {2.15737, 8.22373},
    {2.16794, 8.22122},
    {2.17617, 8.21907},
    {2.20113, 8.21657},
    {2.21498, 7.80791},
    {2.24515, 7.80579},
    {2.28468, 7.80318},
    {2.30964, 7.80111},
    {2.31566, 7.79869},
    {2.31984, 7.7972},
    {2.29937, 7.7957},
    {2.26807, 7.7944},
    {2.21192, 7.79359},
    {2.17482, 7.79289},
    {2.16007, 8.15561},
    {2.16513, 8.15595},
    {2.17371, 8.15571},
    {2.20199, 8.15584},
    {2.26191, 8.15567},
    {2.3069, 8.15535},
    {2.35603, 8.15505},
    {2.37149, 8.15396},
    {2.37534, 8.15345},
    {2.38096, 8.1527},
    {2.33455, 8.56505},
    {2.29915, 8.56434},
    {2.26877, 8.56329},
    {2.25251, 8.56283},
    {2.25842, 8.56205},
    {2.26274, 8.56225},
    {2.27143, 8.56247},
    {2.29047, 8.56251},
    {2.29543, 8.5629},
    {2.30255, 8.5635},
    {2.19421, 8.94},
    {2.17882, 8.94082},
    {2.16724, 8.94138},
    {2.17167, 8.94199},
    {2.17669, 8.94255},
    {2.23872, 8.94277},
    {2.24448, 8.94295},
    {2.26641, 8.94277},
    {2.26734, 8.94287},
    {2.25086, 8.94303},
    {2.26871, 8.89098},
    {2.26951, 8.89149},
    {2.23677, 8.89203},
    {2.19362, 8.89332},
    {2.19603, 8.89452},
    {2.19851, 8.89603},
    {2.21255, 8.89756},
    {2.26336, 8.89938},
    {2.28627, 8.90121},
    {2.29307, 8.90252},
    {2.25912, 9.06736},
    {2.25996, 9.06826},
    {2.2361, 9.06916},
    {2.2332, 9.06996},
    {2.23517, 9.07066},
    {2.2368, 9.07119},
    {2.26169, 9.07173},
    {2.26919, 9.07174},
    {2.27081, 9.07178},
    {2.27899, 9.07183},
    {2.30696, 9.52897},
    {2.3062, 9.52878},
    {2.30301, 9.52859},
    {2.28081, 9.52897},
    {2.24597, 9.52932},
    {2.22387, 9.53059},
    {2.22069, 9.53185},
    {2.21863, 9.53321},
    {2.21862, 9.53454},
    {2.21925, 9.53602},
    {2.20494, 9.63988},
    {2.31885, 9.64075},
    {2.32549, 9.64162},
    {2.32581, 9.64171},
    {2.32179, 9.6418},
    {2.32017, 9.64134},
    {2.28826, 9.64088},
    {2.26329, 9.64044},
    {2.2175, 9.64005},
    {2.19508, 9.63962},
    {2.26395, 9.3744},
    {2.26301, 9.37413},
    {2.26917, 9.37383},
    {2.2876, 9.37366},
    {2.31317, 9.3734},
    {2.33821, 9.37323},
    {2.36541, 9.37305},
    {2.377, 9.37259},
    {2.3775, 9.37217},
    {2.37834, 9.37189},
    {2.33939, 9.2229},
    {2.32079, 9.22224},
    {2.30013, 9.22158},
    {2.29425, 9.22026},
    {2.29544, 9.21889},
    {2.29618, 9.21674},
    {2.29785, 9.21459},
    {2.31347, 9.21188},
    {2.32739, 9.20915},
    {2.33428, 9.20614},
    {2.33613, 9.51315},
    {2.33762, 9.51015},
    {2.3371, 9.50703},
    {2.32407, 9.50449},
    {2.30403, 9.50192},
    {2.28928, 9.50006},
    {2.26108, 9.4982},
    {2.26189, 9.49618},
    {2.26181, 9.49427},
    {2.27011, 9.49217},
    {2.22257, 10.0132},
    {2.2565, 10.0108},
    {2.28918, 10.0083},
    {2.2897, 10.0053},
    {2.28993, 10.0024},
    {2.26318, 9.9995},
    {2.23384, 9.99659},
    {2.21584, 9.9937},
    {2.21516, 9.99081},
    {2.21445, 9.98779},
    {2.25995, 10.137},
    {2.27212, 10.1335},
    {2.2824, 10.13},
    {2.29085, 10.1264},
    {2.29069, 10.1228},
    {2.29023, 10.1191},
    {2.2837, 10.1156},
    {2.27254, 10.112},
    {2.26154, 10.1061},
    {2.26538, 10.0973},
    {2.36167, 9.90399},
    {2.37189, 9.8948},
    {2.40009, 9.88208},
    {2.42268, 9.86956},
    {2.43942, 9.8565},
    {2.43708, 9.84628},
    {2.43027, 9.83595},
    {2.43865, 9.82187},
    {2.46082, 9.81099},
    {2.48301, 9.79983},
    {2.49139, 9.12822},
    {2.61457, 9.11589},
    {2.6376, 9.10344},
    {2.65978, 9.09042},
    {2.69226, 9.07459},
    {2.61283, 9.05874},
    {2.58146, 9.04561},
    {2.55498, 9.03087},
    {2.52975, 9.01613},
    {2.522, 9.00421},
    {2.7978, 7.0442},
    {2.80302, 7.03432},
    {2.82645, 7.02443},
    {2.89282, 7.0148},
    {2.97588, 7.00513},
    {3.01757, 6.99454},
    {3.01745, 6.98386},
    {3.01701, 6.9727},
    {2.93449, 6.96154},
    {2.82943, 6.95052},
    {3.02126, 4.85897},
    {2.89328, 4.84701},
    {2.84602, 4.83506},
    {2.83198, 4.82217},
    {2.83167, 4.80928},
    {2.83137, 4.79518},
    {2.8817, 4.78107},
    {2.96647, 4.76562},
    {3.0591, 4.75017},
    {3.08273, 4.73429},
    {-2.845, 3.67809},
    {-2.84303, 3.66248},
    {-2.90598, 3.64873},
    {-3.02667, 3.6361},
    {3.14157, 3.62742},
    {3.13095, 3.62045},
    {-3.12388, 3.61794},
    {-3.08669, 3.61691},
    {-3.05744, 3.6142},
    {-3.00749, 3.61725},
    {2.89022, 4.73818},
    {2.92324, 4.72707},
    {2.95842, 4.71639},
    {2.98303, 4.70588},
    {3.01992, 4.69857},
    {3.03012, 4.6898},
    {3.01734, 4.68482},
    {3.02848, 4.68106},
    {2.99703, 4.67486},
    {2.99648, 4.67489},
    {2.45611, 5.97274},
    {2.45712, 5.95924},
    {2.46654, 5.94648},
    {2.47748, 5.937},
    {2.47093, 5.92783},
    {2.56246, 5.92154},
    {2.71426, 5.91581},
    {2.82154, 5.91278},
    {2.8001, 5.91008},
    {2.75488, 5.91106},
    {2.33507, 5.35391},
    {2.24644, 5.36319},
    {2.1713, 5.37566},
    {2.08999, 5.39064},
    {2.00923, 5.40853},
    {1.99568, 5.41626},
    {1.98215, 5.42412},
    {2.00096, 5.44126},
    {2.08622, 5.45376},
    {2.21587, 5.47494},
    {3.09359, 3.22302},
    {-3.09212, 3.22525},
    {-3.13416, 3.22893},
    {3.12616, 3.23417},
    {3.07964, 3.24122},
    {2.9661, 3.25052},
    {2.84202, 3.26028},
    {2.75927, 3.2735},
    {2.67893, 3.28756},
    {2.94227, 1.78835},
    {2.89739, 1.79663},
    {2.8466, 1.80452},
    {2.79628, 1.81407},
    {2.77227, 1.82151},
    {2.78408, 1.82965},
    {2.87603, 1.83555},
    {2.94084, 1.84173},
    {2.95643, 1.84503},
    {2.97196, 1.84851},
    {2.94816, 2.83201},
    {2.8923, 2.83445},
    {2.88137, 2.83965},
    {2.89949, 2.84629},
    {2.85636, 2.85633},
    {2.87008, 2.86753},
    {2.89678, 2.87908},
    {2.92328, 2.89108},
    {2.96112, 2.90242},
    {3.11358, 2.91427},
    {-2.95501, 2.92936},
    {2.6329, 5.31907},
    {2.67393, 5.3114},
    {2.71497, 5.3051},
    {2.64669, 5.30258},
    {2.62251, 5.29759},
    {2.57747, 5.29593},
    {2.56013, 5.2948},
    {2.49174, 5.29431},
    {2.47488, 5.29427},
    {2.50915, 5.29355},
    {2.27897, 6.07166},
    {2.30226, 6.06998},
    {2.41219, 6.06548},
    {2.43614, 6.06517},
    {2.46598, 6.064},
    {2.48009, 6.06521},
    {2.47034, 6.06756},
    {2.48425, 6.06801},
    {2.48603, 6.07085},
    {2.48692, 6.07386},
    {2.91281, 4.61854},
    {2.92511, 4.61938},
    {2.92746, 4.6204},
    {2.92369, 4.6212},
    {2.92059, 4.62207},
    {2.91306, 4.62408},
    {2.90142, 4.62631},
    {2.89321, 4.62902},
    {2.88425, 4.63195},
    {2.7245, 2.27016},
    {2.72112, 2.2739},
    {2.72695, 2.27827},
    {2.72965, 2.28264},
    {2.75059, 2.28643},
    {2.81833, 2.29024},
    {2.89141, 2.29361},
    {2.93207, 2.29699},
    {2.93536, 2.30133},
    {2.93724, 2.30568},
    {2.93681, 2.31008},
    {2.67638, 1.44783},
    {2.67397, 1.45389},
    {2.67366, 1.45995},
    {2.67353, 1.46705},
    {2.68263, 1.47377},
    {2.71148, 1.48062},
    {2.7343, 1.48749},
    {2.77931, 1.49435},
    {2.81934, 1.50124},
    {2.45712, 1.43236},
    {2.50746, 1.43754},
    {2.56549, 1.44284},
    {2.60608, 1.44838},
    {2.64688, 1.45492},
    {2.65038, 1.46157},
    {2.65271, 1.46959},
    {2.63886, 1.47762},
    {2.61871, 1.48686},
    {2.62057, 1.49592},
    {2.37382, 1.57698},
    {2.38157, 1.5853},
    {2.39854, 1.59508},
    {2.42027, 1.60481},
    {2.49512, 1.61389},
    {2.56294, 1.6245},
    {2.6342, 1.63371},
    {2.71628, 1.64286},
    {2.78708, 1.65417},
    {2.82803, 1.66535},
    {2.60119, 1.5356},
    {2.58785, 1.54641},
    {2.56261, 1.56118},
    {2.50766, 1.57567},
    {2.46192, 1.58554},
    {2.40843, 1.59871},
    {2.37049, 1.60948},
    {2.34868, 1.62},
    {2.33396, 1.62994},
    {2.31934, 1.63964},
    {2.31051, 1.653},
    {1.49951, 2.12089},
    {1.49062, 2.12628},
    {1.49578, 2.13111},
    {1.51668, 2.1332},
    {1.52428, 2.13732},
    {1.55507, 2.13914},
    {1.57625, 2.14074},
    {1.58121, 2.14385},
    {1.56386, 2.14677},
    {1.19294, 2.12898},
    {1.14423, 2.12944},
    {1.06807, 2.13386},
    {0.984267, 2.13798},
    {0.902557, 2.14227},
    {0.815368, 2.14779},
    {0.737254, 2.15274},
    {0.673469, 2.1576},
    {0.603783, 2.16217},
    {0.535056, 2.16667},
    {0.140949, 2.23642},
    {0.125438, 2.23925},
    {0.106529, 2.24233},
    {0.0891739, 2.24525},
    {0.201187, 2.25005},
    {0.256901, 2.2544},
    {0.296958, 2.26172},
    {0.360901, 2.26895},
    {0.348265, 2.2776},
    {0.332008, 2.28607},
    {0.535228, 3.69534},
    {0.482133, 3.70852},
    {0.360268, 3.72416},
    {0.235359, 3.73939},
    {0.126743, 3.75421},
    {0.0297845, 3.76782},
    {0.000232045, 3.77802},
    {-0.0291459, 3.78763},
    {-0.0556628, 3.79301},
    {-0.037583, 3.79911},
    {-0.00450517, 3.80288},
    {0.737123, 6.25243},
    {0.773686, 6.26785},
    {0.780733, 6.28512},
    {0.767804, 6.30143},
    {0.744346, 6.31786},
    {0.723966, 6.33464},
    {0.712949, 6.35146},
    {0.674082, 6.36968},
    {0.598793, 6.38616},
    {1.41688, 8.84603},
    {1.39008, 8.86122},
    {1.37643, 8.87574},
    {1.36338, 8.89019},
    {1.37818, 8.89931},
    {1.39897, 8.90222},
    {1.44845, 8.89881},
    {1.49184, 8.89524},
    {1.52373, 8.894},
    {1.54668, 8.8931},
    {2.12371, 9.53941},
    {2.15929, 9.54858},
    {2.1457, 9.55786},
    {2.12774, 9.57078},
    {2.08689, 9.58037},
    {2.04063, 9.59912},
    {2.00454, 9.61135},
    {1.97106, 9.62385},
    {1.91869, 9.6458},
    {1.87296, 9.66447},
    {2.01118, 9.83908},
    {1.96463, 9.85663},
    {1.92854, 9.87481},
    {1.89573, 9.90244},
    {1.87459, 9.92087},
    {1.84943, 9.94868},
    {1.86111, 9.96732},
    {1.85952, 9.98561},
    {1.86354, 10.013},
    {1.87864, 10.0308},
    {1.88308, 10.0567},
    {1.98265, 9.49605},
    {1.99868, 9.51292},
    {2.0082, 9.53767},
    {2.0068, 9.55319},
    {1.97563, 9.57644},
    {1.95508, 9.59125},
    {1.92264, 9.60574},
    {1.86942, 9.62746},
    {1.81884, 9.64092},
    {1.91117, 9.97183},
    {1.88611, 9.98572},
    {1.86586, 9.99839},
    {1.83446, 10.0181},
    {1.85377, 10.0289},
    {1.86182, 10.0456},
    {1.89092, 10.0546},
    {1.89679, 10.063},
    {1.88868, 10.0778},
    {1.88293, 10.0853},
    {2.01484, 9.65164},
    {1.99421, 9.6604},
    {1.97337, 9.66915},
    {1.94168, 9.68306},
    {1.88958, 9.69076},
    {1.84571, 9.70306},
    {1.78006, 9.70944},
    {1.73661, 9.71534},
    {1.68336, 9.72563},
    {1.65215, 9.73036},
    {1.6213, 9.73909},
    {1.86897, 8.54498},
    {1.85544, 8.55186},
    {1.82873, 8.56277},
    {1.80838, 8.56863},
    {1.77774, 8.57816},
    {1.75759, 8.58352},
    {1.7376, 8.58851},
    {1.70683, 8.5979},
    {1.69604, 8.603},
    {1.68603, 8.6117},
    {1.98296, 6.23716},
    {2.00375, 6.24409},
    {2.01802, 6.25475},
    {2.05506, 6.26113},
    {2.07952, 6.27095},
    {2.12066, 6.27658},
    {2.12852, 6.28192},
    {2.13578, 6.2904},
    {2.1262, 6.29495},
    {2.42635, 3.78718},
    {2.41842, 3.79371},
    {2.41022, 3.80347},
    {2.39934, 3.81281},
    {2.40299, 3.81856},
    {2.39924, 3.82667},
    {2.41265, 3.83185},
    {2.4194, 3.83692},
    {2.43729, 3.84233},
    {2.4682, 3.84768},
    {2.98257, 2.09947},
    {2.99845, 2.10516},
    {3.03941, 2.11077},
    {3.02523, 2.1197},
    {3.00646, 2.12546},
    {2.98675, 2.13383},
    {2.96805, 2.13969},
    {2.97461, 2.14892},
    {3.00905, 2.15809},
    {3.03719, 2.16393},
    {-2.74586, 1.36087},
    {-2.69112, 1.36684},
    {-2.61189, 1.37327},
    {-2.55746, 1.37954},
    {-2.5456, 1.3856},
    {-2.55301, 1.39389},
    {-2.51489, 1.39947},
    {-2.49429, 1.40504},
    {-2.47578, 1.4138},
    {-2.44857, 1.41952},
    {-2.88408, 1.97043},
    {-2.90085, 1.97614},
    {-2.89274, 1.98136},
    {-2.90653, 1.98926},
    {-2.86881, 1.99331},
    {-2.78211, 1.99924},
    {-2.72272, 2.00228},
    {-2.71382, 2.00517},
    {-2.71318, 2.01058},
    {-2.70312, 2.0133},
    {2.96965, 4.60564},
    {2.97523, 4.60468},
    {2.96433, 4.60324},
    {2.93858, 4.60259},
    {2.99133, 4.60009},
    {2.96557, 4.59801},
    {2.97857, 4.5938},
    {2.96376, 4.59015},
    {2.9629, 4.58529},
    {2.97454, 4.57966},
    {2.3161, 7.54879},
    {2.30882, 7.54068},
    {2.28924, 7.53237},
    {2.27429, 7.52414},
    {2.25549, 7.51672},
    {2.22789, 7.50863},
    {2.20927, 7.5025},
    {2.18005, 7.49545},
    {2.14666, 7.48935},
    {2.11416, 7.48428},
    {2.34849, 9.60862},
    {2.29672, 9.60245},
    {2.26231, 9.59722},
    {2.23668, 9.59205},
    {2.21436, 9.5873},
    {2.17529, 9.58202},
    {2.14259, 9.57754},
    {2.10758, 9.57248},
    {2.05568, 9.56869},
    {2.02473, 9.56557},
    {2.25222, 9.41622},
    {2.20893, 9.41274},
    {2.16109, 9.41013},
    {2.11193, 9.40752},
    {2.06069, 9.40633},
    {2.00377, 9.40467},
    {1.9514, 9.40528},
    {1.89902, 9.40582},
    {1.83491, 9.40784},
    {1.7772, 9.41024},
    {2.15581, 7.53151},
    {2.09326, 7.53633},
    {2.01884, 7.54337},
    {1.94306, 7.55007},
    {1.86542, 7.55804},
    {1.78532, 7.56555},
    {1.71642, 7.5739},
    {1.59439, 7.58162},
    {1.41367, 7.5898},
    {1.36154, 7.5983},
    {1.24139, 5.18169},
    {1.20678, 5.19026},
    {1.18814, 5.1996},
    {1.16418, 5.20865},
    {1.14478, 5.21829},
    {1.11694, 5.22624},
    {1.09619, 5.23547},
    {1.07371, 5.24433},
    {1.04098, 5.25119},
    {1.01806, 5.25927},
    {1.1336, 3.85465},
    {1.11076, 3.86416},
    {1.07628, 3.87242},
    {1.02527, 3.87602},
    {0.974393, 3.87986},
    {0.91434, 3.87837},
    {0.876238, 3.87768},
    {0.840563, 3.87594},
    {0.792248, 3.87276},
    {0.756667, 3.87246},
    {1.05311, 4.4383},
    {1.04181, 4.44619},
    {1.03052, 4.4535},
    {1.02714, 4.4605},
    {1.05605, 4.46592},
    {1.05255, 4.47331},
    {1.05324, 4.47981},
    {1.0537, 4.48632},
    {1.05819, 4.49288},
    {1.05631, 4.4996},
    {1.60005, 5.28251},
    {1.59695, 5.28708},
    {1.58698, 5.29118},
    {1.59186, 5.29461},
    {1.57814, 5.29882},
    {1.5658, 5.30295},
    {1.51356, 5.30655},
    {1.48314, 5.31106},
    {1.44619, 5.314},
    {1.41937, 5.31773},
    {1.97306, 4.68467},
    {1.97282, 4.68703},
    {1.97292, 4.6877},
    {1.99709, 4.68837},
    {2.03408, 4.68745},
    {2.07219, 4.6864},
    {2.10477, 4.68445},
    {2.12166, 4.6825},
    {2.15354, 4.67957},
    {2.16251, 4.67665},
    {2.20216, 3.31349},
    {2.21443, 3.31027},
    {2.22719, 3.30655},
    {2.24575, 3.29822},
    {2.25879, 3.28909},
    {2.28216, 3.2763},
    {2.30552, 3.26347},
    {2.3247, 3.2507},
    {2.3551, 3.23216},
    {2.37558, 3.2185},
    {3.07603, 2.07035},
    {3.11409, 2.05995},
    {-3.12777, 2.05004},
    {-3.07826, 2.03463},
    {-3.04475, 2.02596},
    {-3.00277, 2.01382},
    {-2.97045, 2.00672},
    {-2.93195, 2.00021},
    {-2.89083, 1.98973},
    {-2.84742, 1.98521},
    {-2.84355, 2.38134},
    {-2.8054, 2.37634},
    {-2.76413, 2.37191},
    {-2.72745, 2.36809},
    {-2.69253, 2.3642},
    {-2.65406, 2.35764},
    {-2.62554, 2.35485},
    {-2.60132, 2.3527},
    {-2.57144, 2.34766},
    {-2.53202, 2.34368},
    {-2.7796, 4.07041},
    {-2.75369, 4.06666},
    {-2.73314, 4.06365},
    {-2.69583, 4.05286},
    {-2.6789, 4.04629},
    {-2.64911, 4.04103},
    {-2.60058, 4.037},
    {-2.52913, 4.034},
    {-2.43589, 4.02942},
    {-2.39733, 4.03155},
    {-2.88905, 5.31473},
    {-2.83214, 5.3097},
    {-2.80607, 5.30688},
    {-2.73701, 5.30218},
    {-2.67491, 5.30032},
    {-2.59893, 5.29732},
    {-2.55709, 5.29633},
    {-2.50426, 5.29572},
    {-2.44323, 5.2936},
    {-2.40503, 5.29364},
    {-2.98511, 5.00553},
    {-2.96077, 5.00192},
    {-2.95, 4.99882},
    {-2.91885, 4.99453},
    {-2.91582, 4.99204},
    {-2.88829, 4.98865},
    {-2.87088, 4.98631},
    {-2.85124, 4.98406},
    {-2.81379, 4.98056},
    {-2.79261, 4.97843},
    {-3.09445, 3.92599},
    {-3.07521, 3.92362},
    {-3.0567, 3.92145},
    {-3.0198, 3.91812},
    {-3.00684, 3.91618},
    {-2.98203, 3.9132},
    {-2.97545, 3.91109},
    {-2.96439, 3.90884},
    {-2.94286, 3.90507},
    {-2.92686, 3.90249},
    {2.917, 3.89963},
    {2.93402, 3.89853},
    {2.95603, 3.89709},
    {2.98984, 3.89413},
    {3.01112, 3.89275},
    {3.03809, 3.89039},
    {3.05664, 3.88953},
    {3.0814, 3.88845},
    {3.10987, 3.88692},
    {3.12569, 3.8869},
    {2.90557, 5.36504},
    {2.92197, 5.36637},
    {2.95338, 5.36744},
    {2.98618, 5.36609},
    {3.02679, 5.36476},
    {3.06514, 5.36121},
    {3.10192, 5.35877},
    {3.12433, 5.356},
    {-3.13666, 5.35322},
    {-3.12245, 5.35019},
    {2.89374, 5.71192},
    {2.90327, 5.71073},
    {2.8981, 5.70961},
    {2.92517, 5.70514},
    {2.94407, 5.70002},
    {2.96999, 5.69488},
    {2.98595, 5.69174},
    {3.00324, 5.68817},
    {3.02378, 5.68418},
    {3.04517, 5.67951},
    {2.63969, 6.36336},
    {2.6605, 6.363},
    {2.68134, 6.36201},
    {2.71389, 6.35677},
    {2.74054, 6.35062},
    {2.76842, 6.34466},
    {2.78155, 6.34115},
    {2.79586, 6.33722},
    {2.80273, 6.33284},
    {2.81419, 6.32803},
    {2.59926, 6.76607},
    {2.61179, 6.76348},
    {2.6236, 6.76058},
    {2.65299, 6.75237},
    {2.68205, 6.74338},
    {2.71237, 6.73497},
    {2.73315, 6.72988},
    {2.75925, 6.72435},
    {2.78639, 6.71839},
    {2.81287, 6.71198},
    {2.50639, 7.78407},
    {2.5319, 7.78047},
    {2.55822, 7.77528},
    {2.59191, 7.76443},
    {2.6257, 7.75246},
    {2.65189, 7.74138},
    {2.65976, 7.73457},
    {2.66072, 7.72741},
    {2.673, 7.71399},
    {2.67988, 7.70618},
    {2.45743, 7.95858}
};


ATEST(WrapAroundFilter, QuickSlidingMean2) {
  // WrapAroundFilter f6(new SlidingAverageFilter(1000)); // was QuickSlidingAverageFilter
  WrapAroundFilter f6(new LowPass1Filter(1000)); // was QuickSlidingAverageFilter
  double prev6;
  const int rounds = 2000;
  for (int cnt = 0; cnt < rounds; ++cnt) {
    double in = example[cnt].alpha;
    double out6 = f6.Filter(in);
    printf("%6.4lf\n", out6);

    EXPECT_IN_INTERVAL(0, out6, 2 * M_PI);

    // In steady state, the output follows the input with the same gradient.
    if (cnt > 1000) {
      EXPECT_IN_INTERVAL(-0.1, DeltaOldNewRad(prev6, out6), 0.1);
    }
    if (f6.ValidOutput()) {
        //EXPECT_IN_INTERVAL(1.5, out6, 2.5);
    }

    if (cnt < 999)
      EXPECT_FALSE(f6.ValidOutput());
    if (cnt >= 999)
      EXPECT_TRUE(f6.ValidOutput());

    prev6 = out6;
  }
}

// All these filters except the PolarFilter have a constant runtime in the range of 320ns (Desktop).
// The Polar filter filters in 2 dimensions and calls 3 trigonometric functions.
// It runs in about 630ns.
ATEST(WrapAroundFilter, AllFilterTiming) {
  WrapAroundFilter f1(new SlidingAverageFilter(10));
  WrapAroundFilter f2(new LowPass1Filter(10));
  WrapAroundFilter f3(new Median3Filter());
  WrapAroundFilter f4(new Median5Filter());
  WrapAroundFilter f5(new SlidingAverageFilter(100));
  WrapAroundFilter f6(new QuickSlidingAverageFilter(100));
  PolarFilter f7(new LowPass1Filter(10), new LowPass1Filter(10));
  double prev1;
  double prev2;
  double prev3;
  double prev4;
  double prev5;
  double prev6;
  double prev7;
  double increment = 1;
  int64 micros1 = 0;
  int64 micros2 = 0;
  int64 micros3 = 0;
  int64 micros4 = 0;
  int64 micros5 = 0;
  int64 micros6 = 0;
  int64 micros7 = 0;
  const int rounds = 5000;
  for (int cnt = 0; cnt < rounds; ++cnt) {
    double in = NormalizeRad(cnt * increment);
    int64 n0 = Now();
    double out1 = f1.Filter(in);
    int64 n1 = Now();
    double out2 = f2.Filter(in);
    int64 n2 = Now();
    double out3 = f3.Filter(in);
    int64 n3 = Now();
    double out4 = f4.Filter(in);
    int64 n4 = Now();
    double out5 = f5.Filter(in);
    int64 n5 = Now();
    double out6 = f6.Filter(in);
    int64 n6 = Now();
    Polar out7(0, 0);
    f7.Filter(Polar(in, 1), &out7);
    int64 n7 = Now();
    micros1 += n1 - n0;
    micros2 += n2 - n1;
    micros3 += n3 - n2;
    micros4 += n4 - n3;
    micros5 += n5 - n4;
    micros6 += n6 - n5;
    micros7 += n7 - n6;
    //printf("%6.4lf %6.4lf %6.4lf %6.4lf %6.4lf\n", out1, out2, out3, out4, out5);

    EXPECT_IN_INTERVAL(0, out1, 2 * M_PI);
    EXPECT_IN_INTERVAL(0, out2, 2 * M_PI);
    EXPECT_IN_INTERVAL(0, out3, 2 * M_PI);
    EXPECT_IN_INTERVAL(0, out4, 2 * M_PI);
    EXPECT_IN_INTERVAL(0, out5, 2 * M_PI);
    EXPECT_IN_INTERVAL(0, out6, 2 * M_PI);
    EXPECT_IN_INTERVAL(-M_PI, out7.AngleRad(), M_PI);

    // In steady state, the output follows the input with the same gradient.
    if (cnt > 200) {
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev1, out1));
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev2, out2));
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev3, out3));
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev4, out4));
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev5, out5));
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev6, out6));
      EXPECT_FLOAT_EQ(increment, DeltaOldNewRad(prev7, out7.AngleRad()));
    }
    if (cnt < 99)
      EXPECT_FALSE(f5.ValidOutput());
    if (cnt >= 99)
      EXPECT_TRUE(f5.ValidOutput());
    if (cnt < 49)
      EXPECT_FALSE(f6.ValidOutput());
    if (cnt >= 49)
      EXPECT_TRUE(f6.ValidOutput());

    prev1 = out1;
    prev2 = out2;
    prev3 = out3;
    prev4 = out4;
    prev5 = out5;
    prev6 = out6;
    prev7 = out7.AngleRad();
  }
  printf("\nRuntimes/microseconds\n=================\n");
  printf("SlidingAverageFilter:    %6.4lf micros\n", micros1 / static_cast<double>(rounds));
  printf("LowPass1Filter:          %6.4lf micros\n", micros2 / static_cast<double>(rounds));
  printf("Median3Filter:           %6.4lf micros\n", micros3 / static_cast<double>(rounds));
  printf("Median5Filter:           %6.4lf micros\n", micros4 / static_cast<double>(rounds));
  printf("SlidingAverageFilter100: %6.4lf micros\n", micros5 / static_cast<double>(rounds));
  printf("QuickSlidingAverageFilter100: %6.4lf micros\n", micros6 / static_cast<double>(rounds));
  printf("PolarFilter (2 filters): %6.4lf micros\n", micros7 / static_cast<double>(rounds));
  printf("\n");
}

int main(int argc, char* argv[]) {
  return testing::RunAllTests();
}
